package com.weixing.mall.util.number;

import cn.hutool.core.math.Money;

import java.math.BigDecimal;

/**
 * @ClassName MoneyUtil
 * @Description
 * @Author Small
 * @Date 2020/3/29 10:19
 * @Version 1.0
 **/
public class MoneyUtil {

    /**
     * 金额相加
     *
     * @param amount1
     * @param amount2
     * @return
     */
    public static BigDecimal add(BigDecimal amount1,BigDecimal amount2){
        Money money1 = new Money(amount1);
        Money money2 = new Money(amount2);
        Money add = money1.add(money2);
        return add.getAmount();
    }

    /**
     * 金额相乘
     *
     * @param amount1
     * @param amount2
     * @return
     */
    public static BigDecimal mul(BigDecimal amount1,BigDecimal amount2){
        Money money1 = new Money(amount1);
        Money add = money1.multiply(amount2);
        return add.getAmount();
    }

    /**
     * 金额相减
     *
     * @param amount1
     * @param amount2
     * @return
     */
    public static BigDecimal sub(BigDecimal amount1,BigDecimal amount2){
        Money money1 = new Money(amount1);
        Money money2 = new Money(amount2);
        Money add = money1.subtract(money2);
        return add.getAmount();
    }
}
